<?php
	class Server{		
		var $xml;
		public function modify($nowEx,$money,$totalEx,$level,$typeName,$num,$price,$ex,$number){				
		 $fireDir="Services/my-project-restaurnt/res/data/data.xml";
		 if(file_exists($fireDir)){			
			 $xml=simplexml_load_file($fireDir);
			 if($nowEx != null){
				  $xml->global->nowEx = $nowEx;
			 }
			 if($money != null){
				 $xml->global->money = $money;
			 }
			 if($totalEx != null){
				 $xml->global->totalEx = $totalEx;
			 }
			 if($level != null){
				  $xml->global->level = $level;
			 }
			 			
			 switch($number)
			 {
				 case 0:
				 	$xml->menu->first = $typeName;
					$xml->menu->firstPrice = $price;
					$xml->menu->firstNum = $num;
					$xml->menu->firstEx = $ex;
					break;
				 case 1:
				 	$xml->menu->second = $typeName;
					$xml->menu->secondPrice = $price;
					$xml->menu->secondNum = $num;
					$xml->menu->secondEx = $ex;
					break;
				 case 2:
				 	$xml->menu->third = $typeName;
					$xml->menu->thirdNumPrice = $price;
					$xml->menu->thirdNum = $num;
					$xml->menu->thirdNumEx = $ex;
				 	break;
			 }
			 $xml->saveXML("Services/my-project-restaurnt/res/data/data.xml");
			 return "success";
		 }
		 else{
			 //echo 123;
			 return "error";
		 }
		}
	}
?>